package com.imooc.api.controller.files;

import com.imooc.grace.result.GraceJSONResult;
import com.imooc.pojo.bo.NewAdminBO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * 文件服务
 */
@RequestMapping("fs")
public interface FileUploaderControllerApi {

    /**
     * 上传单文件
     */
    @PostMapping("/uploadFace")
    GraceJSONResult uploadFace(@RequestParam String userId, MultipartFile file) throws Exception;

    /**
     * 上传多个文件
     */
    @PostMapping("/uploadSomeFiles")
    GraceJSONResult uploadSomeFiles(@RequestParam String userId, MultipartFile[] files) throws Exception;

    /**
     * 文件上传到MongoDB的gridfs中
     */
    @PostMapping("/uploadToGridFS")
    GraceJSONResult uploadToGridFS(@RequestBody NewAdminBO newAdminBO) throws Exception;

    /**
     * 从GridFS中读取图片内容
     */
    @GetMapping("/readInGridFS")
    void readInGridFS(String faceId, HttpServletResponse response) throws Exception;

    /**
     * 从gridfs中读取图片内容, 并且返回base64
     */
    @GetMapping("/readFace64InGridFS")
    GraceJSONResult readFace64InGridFS(String faceId) throws Exception;

}
